package jtcl.tech.kafka.listener;

import jtcl.tech.kafka.dto.KafkaConfigDTO;
import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.listener.BatchAcknowledgingConsumerAwareMessageListener;
import org.springframework.kafka.support.Acknowledgment;

import java.util.List;

/**
 * <p>批量消费实现类</p>
 *
 * @author 施锦庭
 * @since  2021-08-12 15:47
 **/
public interface ConsumerBatchListener extends BatchAcknowledgingConsumerAwareMessageListener<String, String> {

    /**
     * <p>消费者监听配置,会覆盖@KafkaConsumerListener的配置</p>
     *
     * @param config
     * @return cec.ics.common.queue.kafka.KafkaConfigDTO
     * @author 施锦庭
     * @since  2021-08-12 16:02
     **/
    default KafkaConfigDTO config(KafkaConfigDTO config) {
        return null;
    }

    @Override
    void onMessage(List<ConsumerRecord<String, String>> data, Acknowledgment acknowledgment,
                   Consumer<?, ?> consumer);
}
